﻿using Approve.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Approve.Web.Models.Shared
{
    /// <summary>
    /// 全局响应对象
    /// </summary>
    public class ApproveResponse
    {
        /// <summary>
        /// 异常节点
        /// </summary>
        public dynamic Exception { get; set; }

        /// <summary>
        /// 响应数据节点
        /// </summary>
        public dynamic ResponseResult { get; set; }

        /// <summary>
        /// 响应数据格式化
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        public static ApproveResponse Format(dynamic results)
        {
            var excep = ExceptionHelper.Nothing();
            ApproveResponse response = new ApproveResponse();
            response.Exception = new { Has = excep.Has, Code = excep.Code, Message = excep.Message };
            response.ResponseResult = results;
            return response;
        }
        /// <summary>
        /// 响应数据格式化
        /// </summary>
        /// <param name="excep"></param>
        /// <param name="results"></param>
        /// <returns></returns>
        public static ApproveResponse Format(ExceptionHelper excep, dynamic results)
        {
            ApproveResponse response = new ApproveResponse();
            response.Exception = new { Has = excep.Has, Code = excep.Code, Message = excep.Message };
            response.ResponseResult = results;
            return response;
        }
    }
}